﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BasicFrameworkDemo.Winform.App
{
    public partial class LoginView : Form
    {
        private LoginController controllor;

        public LoginController Controllor
        {
            get { return this.controllor; }
            set
            {
                this.controllor = value;
                //绑定一定只能写在给Controllor赋值以后而不能写在PersonForm的构造函数中(此时Controllor还未被实例化)  
                //因为我们这里采用的是Controllor-First而不是View-First，不然Controllor.Model为null会异常  
                //将View通过构造函数注入到Controllor中的属于Controllor-First,这时候Controllor先创建  
                //将Controllor通过构造函数注入到View中的属于View-First,这时候View先创建  
                this.UserName.DataBindings.Add("Text", Controllor.LoginModel, "UserName");
                this.Password.DataBindings.Add("Text", Controllor.LoginModel, "Password");
            }
        }  

        //public LoginController Controllor;

        public LoginView()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Controllor.Login();
        }
    }
}
